home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / sndhrdw / astrof.c < prev    next >
C/C++ Source or Header  |  2000-04-04  |  4KB  |  175 lines

  1.  
  2. #include "driver.h"
  3.  
  4. /* Make sure that the sample name definitions in drivers/astrof.c matches these */
  5.  
  6. #define SAMPLE_FIRE         0
  7. #define SAMPLE_EKILLED     1
  8. #define SAMPLE_WAVE         2
  9. #define SAMPLE_BOSSFIRE  6
  10. #define SAMPLE_FUEL         7
  11. #define SAMPLE_DEATH     8
  12. #define SAMPLE_BOSSHIT     9
  13. #define SAMPLE_BOSSKILL  10
  14.  
  15. #define CHANNEL_FIRE      0
  16. #define CHANNEL_EXPLOSION 1
  17. #define CHANNEL_WAVE      2   /* Background humm */
  18. #define CHANNEL_BOSSFIRE  2      /* There is no background humm on the boss level */
  19. #define CHANNEL_FUEL      3
  20.  
  21.  
  22. /* Make sure that the #define's in sndhrdw/astrof.c matches these */
  23. static const char *astrof_sample_names[] =
  24. {
  25.     "*astrof",
  26.     "fire.wav",
  27.     "ekilled.wav",
  28.     "wave1.wav",
  29.     "wave2.wav",
  30.     "wave3.wav",
  31.     "wave4.wav",
  32.     "bossfire.wav",
  33.     "fuel.wav",
  34.     "death.wav",
  35.     "bosshit.wav",
  36.     "bosskill.wav",
  37.     0   /* end of array */
  38. };
  39.  
  40. struct Samplesinterface astrof_samples_interface =
  41. {
  42.     4,    /* 4 channels */
  43.     25,    /* volume */
  44.     astrof_sample_names
  45. };
  46.  
  47. static const char *tomahawk_sample_names[] =
  48. {
  49.     "*tomahawk",
  50.     /* We don't have these yet */
  51.     0   /* end of array */
  52. };
  53.  
  54. struct Samplesinterface tomahawk_samples_interface =
  55. {
  56.     1,    /* 1 channel for now */
  57.     25,    /* volume */
  58.     tomahawk_sample_names
  59. };
  60.  
  61.  
  62. static int start_explosion = 0;
  63. static int death_playing = 0;
  64. static int bosskill_playing = 0;
  65.  
  66. WRITE_HANDLER( astrof_sample1_w )
  67. {
  68.     static int last = 0;
  69.  
  70.     if (death_playing)
  71.     {
  72.         death_playing = sample_playing(CHANNEL_EXPLOSION);
  73.     }
  74.  
  75.     if (bosskill_playing)
  76.     {
  77.         bosskill_playing = sample_playing(CHANNEL_EXPLOSION);
  78.     }
  79.  
  80.     /* Bit 2 - Explosion trigger */
  81.     if ((data & 0x04) && !(last & 0x04))
  82.     {
  83.         /* I *know* that the effect select port will be written shortly
  84.            after this one, so this works */
  85.         start_explosion = 1;
  86.     }
  87.  
  88.     /* Bit 0/1/3 - Background noise */
  89.     if ((data & 0x08) != (last & 0x08))
  90.     {
  91.         if (data & 0x08)
  92.         {
  93.             int sample = SAMPLE_WAVE + (data & 3);
  94.             sample_start(CHANNEL_WAVE,sample,1);
  95.         }
  96.         else
  97.         {
  98.             sample_stop(CHANNEL_WAVE);
  99.         }
  100.     }
  101.  
  102.     /* Bit 4 - Boss Laser */
  103.     if ((data & 0x10) && !(last & 0x10))
  104.     {
  105.         if (!bosskill_playing)
  106.         {
  107.             sample_start(CHANNEL_BOSSFIRE,SAMPLE_BOSSFIRE,0);
  108.         }
  109.     }
  110.  
  111.     /* Bit 5 - Fire */
  112.     if ((data & 0x20) && !(last & 0x20))
  113.     {
  114.         if (!bosskill_playing)
  115.         {
  116.             sample_start(CHANNEL_FIRE,SAMPLE_FIRE,0);
  117.         }
  118.     }
  119.  
  120.     /* Bit 6 - Don't know. Probably something to do with the explosion sounds */
  121.  
  122.     /* Bit 7 - Don't know. Maybe a global sound enable bit? */
  123.  
  124.     last = data;
  125. }
  126.  
  127.  
  128. WRITE_HANDLER( astrof_sample2_w )
  129. {
  130.     static int last = 0;
  131.  
  132.     /* Bit 0-2 Explosion select (triggered by Bit 2 of the other port */
  133.     if (start_explosion)
  134.     {
  135.         if (data & 0x04)
  136.         {
  137.             /* This is really a compound effect, made up of I believe 3 sound
  138.                effects, but since our sample contains them all, disable playing
  139.                the other effects while the explosion is playing */
  140.             if (!bosskill_playing)
  141.             {
  142.                 sample_start(CHANNEL_EXPLOSION,SAMPLE_BOSSKILL,0);
  143.                 bosskill_playing = 1;
  144.             }
  145.         }
  146.         else if (data & 0x02)
  147.         {
  148.             sample_start(CHANNEL_EXPLOSION,SAMPLE_BOSSHIT,0);
  149.         }
  150.         else if (data & 0x01)
  151.         {
  152.             sample_start(CHANNEL_EXPLOSION,SAMPLE_EKILLED,0);
  153.         }
  154.         else
  155.         {
  156.             if (!death_playing)
  157.             {
  158.                 sample_start(CHANNEL_EXPLOSION,SAMPLE_DEATH,0);
  159.                 death_playing = 1;
  160.             }
  161.         }
  162.  
  163.         start_explosion = 0;
  164.     }
  165.  
  166.     /* Bit 3 - Low Fuel Warning */
  167.     if ((data & 0x08) && !(last & 0x08))
  168.     {
  169.         sample_start(CHANNEL_FUEL,SAMPLE_FUEL,0);
  170.     }
  171.  
  172.     last = data;
  173. }
  174.  
  175.